package xyz.xmh.pattern.behavioral.visitorpattern;

/**
 * @author Administrator
 * <p>
 * 实现了电脑部分接口的实体类，电脑
 */
public class Computer implements ComputerPart {

    private final ComputerPart[] computerParts;

    public Computer() {
        computerParts = new ComputerPart[]{new Mouse(), new Keyboard(), new Monitor()};
    }

    @Override
    public void accept(ComputerPartVisitor computerPartVisitor) {

        for (ComputerPart computerPart : computerParts) {
            computerPart.accept(computerPartVisitor);
        }

        computerPartVisitor.visit(this);
    }
}
